//
//  GKDYVideoPortraitCell.m
//  GKDYVideo
//
//  Created by QuintGao on 2023/5/5.
//  Copyright © 2023 QuintGao. All rights reserved.
//

#import "GKDYVideoPortraitCell.h"

@interface GKDYVideoPortraitCell()<GKDYVideoPortraitViewDelegate, UIScrollViewDelegate>
@property (nonatomic, strong) UIScrollView *scrollView;
@end

@implementation GKDYVideoPortraitCell

- (void)initUI {
    [self addSubview:self.scrollView];
    [self.scrollView addSubview:self.coverImgView];
    [self.coverImgView addSubview:self.portraitView];
    [self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
    }];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.coverImgView.frame = self.scrollView.bounds;
    self.portraitView.frame = self.coverImgView.bounds;
}

- (void)loadData:(WSVideo *)model {
    [super loadData:model];
    self.portraitView.model = model;
}

- (void)resetView {
    [super resetView];
    self.portraitView.hidden = NO;
    self.portraitView.frame = self.coverImgView.bounds;
    [self.coverImgView addSubview:self.portraitView];
}

#pragma mark - GKDYVideoPortraitViewDelegate
- (void)didClickChapter:(WSVideo *)model {
    if ([self.delegate respondsToSelector:@selector(videoCell:didClickChapter:)]) {
        [self.delegate videoCell:self didClickChapter:model];
    }
}

- (void)didClickLike:(WSVideo *)model {
    if ([self.delegate respondsToSelector:@selector(videoCell:didClickLike:)]) {
        [self.delegate videoCell:self didClickLike:model];
    }
}

#pragma mark - Lazy
- (UIScrollView *)scrollView {
    if (!_scrollView) {
        _scrollView = [[UIScrollView alloc] init];
        _scrollView.delegate = self;
        _scrollView.backgroundColor = UIColor.clearColor;
        _scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        _scrollView.showsVerticalScrollIndicator = NO;
        _scrollView.showsHorizontalScrollIndicator = NO;
        _scrollView.minimumZoomScale = 1.0f;
        _scrollView.maximumZoomScale = 10.0f;
    }
    return _scrollView;
}

- (GKDYVideoPortraitView *)portraitView {
    if (!_portraitView) {
        _portraitView = [[GKDYVideoPortraitView alloc] initWithFrame:UIScreen.mainScreen.bounds];
        _portraitView.delegate = self;
    }
    return _portraitView;
}

@end
